﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 超市收银系统
{
    class CangKu
    {
        List<List<ProductFather>> list = new List<List<ProductFather>>();
        #region 构造方法，在创建仓库对象时给仓库添加货架
        public CangKu()
        {
            list.Add(new List<ProductFather>());
            list.Add(new List<ProductFather>());
            list.Add(new List<ProductFather>());
            list.Add(new List<ProductFather>());
        }
        #endregion
        #region 进货
        public void GetProducts(string producttypes,int count)
        {
            for (int i = 0; i < count; i++) {
                switch (producttypes)
                {
                    case "Acer笔记本":
                        list[0].Add(new Acer笔记本(Guid.NewGuid().ToString(), "Acer笔记本", 7000));
                        break;
                    case "Banana":
                        list[1].Add(new Banana(Guid.NewGuid().ToString(), "香蕉", 20));
                        break;
                    case "JiangYou":
                        list[2].Add(new JiangYou(Guid.NewGuid().ToString(), "酱油", 7));
                        break;
                    case "SanXing":
                        list[3].Add(new SanXing(Guid.NewGuid().ToString(), "三星手机", 3000));
                        break;
                        #endregion

                }
            }
        }
        #region 取货
        public ProductFather[] OutProducts(string producttype,int count)
        {
            ProductFather[] product = new ProductFather[count];
            for (int i = 0; i <count; i++)
            {
                switch (producttype)
                {
                    case "Acer笔记本":
                        product[i] = list[0][0];
                        list[0].RemoveAt(0);
                        break;
                    case "Banana":
                        product[i] = list[1][0];
                        list[1].RemoveAt(0);
                        break;
                    case "JiangYou":
                        product[i] = list[2][0];
                        list[2].RemoveAt(0);
                        break;
                    case "SanXing":
                        product[i] = list[3][0];
                        list[3].RemoveAt(0);
                        break;
                }
            }
            return product;
        }
        #endregion
        #region 展示仓库货物
        public void ShowProducts()
        {
            foreach(var item in list)
            {
                Console.WriteLine("我们超市有{0}个{1}，每个{2}元", item.Count, item[0].Name,item[0].Price);
            }
        }
        #endregion
    }
}
